﻿@if (!User.Identity.IsAuthenticated)
{
	<script type="text/javascript">
		$().ready(function () {
			$('#modal-account-logon div.btn-group button').click(function (e) {
				e.preventDefault();

				var $button = $(this);

				if ($button.hasClass('active')) {
					return;
				} else {

					$('button', $button.parent()).removeClass('active');

					$('#modal-account-logon > div:not(.modal-header):not(:hidden)').hide();
					$('div.' + $button.attr('id')).show();
				}
			});
		});
		
		@if (!string.IsNullOrWhiteSpace(ViewBag.RepairEmail) && !string.IsNullOrWhiteSpace(ViewBag.RepairCode))
		{
<text>
		$().ready(function () {
			var $acc = $('#modal-account-logon');
			$('div.modal-header button.active', $acc).removeClass('active');
			$('div.modal-header #account-repair', $acc).addClass('active');

			$('div.account-logon', $acc).hide();
			$('div.account-repair', $acc).add($('form.account-update-password', $acc)).show();

			$('form.account-repair-password input[name="Email"]', $acc).add($('form.account-update-password input[name="Email"]', $acc)).val('@ViewBag.RepairEmail');
			$('form.account-update-password input[name="HashCode"]', $acc).val('@ViewBag.RepairCode');

			$('#modal-account-logon').modal();
		});

</text>
		}
	</script>
	<div id="modal-account-logon" class="modal hide" data-backdrop="static">
		<div class="modal-header">
			<div data-toggle="buttons-checkbox" class="btn-group">
				<button id="account-logon" class="btn active" type="button">Вход</button>
				<button id="account-create" class="btn" type="button">Регистрация</button>
				<button id="account-repair" class="btn" type="button">Востановление</button>
			</div>
		</div>
		<div class="account-logon">@Html.Partial("_AccountLogonDialog", new Smarly.Bussines.Model.Account.Login())</div>
		<div class="account-create hide">@Html.Partial("_AccountCreateDialog", new Smarly.Bussines.Model.Account.NewAccount())</div>
		<div class="account-repair hide">@Html.Partial("_AccountUpdateDialog", new Smarly.Bussines.Model.Account.UpdatePassword())</div>
	</div>	 
}

